package cn.pomit.springbootwork.oauthclient2.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.pomit.springbootwork.oauthclient2.model.ResultModel;

@RestController
@RequestMapping("/remote")
public class OauthRemoteRest {
	@Value("${remote.ipUrl}")
	private String remoteIpUrl;
	@Autowired
	private OAuth2RestTemplate oAuth2RestTemplate;
	
	@RequestMapping(value = "/ip", method = { RequestMethod.GET })
	public ResultModel ip(HttpServletRequest request) {
		ResultModel rm = oAuth2RestTemplate.getForObject(remoteIpUrl, ResultModel.class);
		return rm;
	}
}
